```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring Boot邮件发送教程 | 技术小馆</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=NotoSans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', 'Noto Serif SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.8;
        }
        .hero-title {
            text-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        .card {
            transition: all 0.3s ease;
            box-shadow: 0 4px 6px rgba(0,0,0,0.05);
        }
        .card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        }
        .code-block {
            background: #f8f9fa;
            border-left: 4px solid #4a90e2;
        }
        .step-icon {
            width: 40px;
            height: 40px;
            background: #4a90e2;
            color: white;
        }
        a {
            color: #4a90e2;
            transition: all 0.2s ease;
        }
        a:hover {
            color: #2c5282;
            text-decoration: underline;
        }
        .mermaid {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.05);
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="relative py-20 bg-gradient-to-r from-blue-500 to-indigo-600 text-white">
        <div class="container mx-auto px-6 text-center">
            <div class="max-w-3xl mx-auto">
                <h1 class="text-4xl md:text-5xl font-bold hero-title mb-6">Spring Boot邮件发送全攻略</h1>
                <p class="text-xl md:text-2xl opacity-90 mb-8">从零开始掌握Spring Boot整合邮件发送服务的最佳实践</p>
                <div class="flex justify-center space-x-4">
                    <span class="px-4 py-2 bg-white bg-opacity-20 rounded-lg"><i class="fas fa-code mr-2"></i>Java</span>
                    <span class="px-4 py-2 bg-white bg-opacity-20 rounded-lg"><i class="fas fa-envelope mr-2"></i>SMTP</span>
                    <span class="px-4 py-2 bg-white bg-opacity-20 rounded-lg"><i class="fas fa-cogs mr-2"></i>Spring Boot</span>
                </div>
            </div>
        </div>
        <div class="absolute bottom-0 left-0 right-0 h-16 bg-white transform skew-y-1 -mb-8 z-10"></div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto px-6 py-16 max-w-5xl">
        <!-- Introduction -->
        <div class="mb-12">
            <p class="text-xl text-gray-700 leading-relaxed mb-6">
                在现代Web应用中，邮件发送是一个常见且重要的功能。本教程将详细介绍如何在Spring Boot项目中集成邮件发送功能，包括SMTP配置、邮件实体封装、工具类编写和实际测试。
            </p>
        </div>

        <!-- Steps Overview -->
        <div class="mb-16">
            <div class="grid grid-cols-1 md:grid-cols-4 gap-6">
                <div class="card bg-white rounded-xl p-6 flex flex-col items-center text-center">
                    <div class="step-icon rounded-full flex items-center justify-center mb-4">
                        <i class="fas fa-user-cog text-xl"></i>
                    </div>
                    <h3 class="font-bold text-lg mb-2">SMTP配置</h3>
                    <p class="text-gray-600">配置邮箱账号和授权码</p>
                </div>
                <div class="card bg-white rounded-xl p-6 flex flex-col items-center text-center">
                    <div class="step-icon rounded-full flex items-center justify-center mb-4">
                        <i class="fas fa-file-import text-xl"></i>
                    </div>
                    <h3 class="font-bold text-lg mb-2">导入依赖</h3>
                    <p class="text-gray-600">添加Spring Mail Starter</p>
                </div>
                <div class="card bg-white rounded-xl p-6 flex flex-col items-center text-center">
                    <div class="step-icon rounded-full flex items-center justify-center mb-4">
                        <i class="fas fa-cog text-xl"></i>
                    </div>
                    <h3 class="font-bold text-lg mb-2">YML配置</h3>
                    <p class="text-gray-600">设置邮件服务器参数</p>
                </div>
                <div class="card bg-white rounded-xl p-6 flex flex-col items-center text-center">
                    <div class="step-icon rounded-full flex items-center justify-center mb-4">
                        <i class="fas fa-paper-plane text-xl"></i>
                    </div>
                    <h3 class="font-bold text-lg mb-2">发送邮件</h3>
                    <p class="text-gray-600">编写工具类进行测试</p>
                </div>
            </div>
        </div>

        <!-- Step 1: SMTP Configuration -->
        <section class="mb-16">
            <div class="flex items-center mb-6">
                <div class="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-user-cog text-blue-600 text-xl"></i>
                </div>
                <h2 class="text-2xl font-bold text-gray-800">1. 开启账号SMTP</h2>
            </div>
            <div class="bg-white rounded-xl overflow-hidden shadow-md mb-6">
                <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1716350253111-f70b51da-efce-44ab-9dba-557a76ff278a.png" 
                     alt="SMTP配置图示" 
                     class="w-full h-auto">
            </div>
            <div class="prose max-w-none">
                <p class="text-gray-700 mb-4">
                    首先需要在邮箱设置中开启SMTP服务，并获取授权码。不同邮箱提供商的开启方式略有不同：
                </p>
                <ul class="list-disc pl-6 mb-6 text-gray-700">
                    <li class="mb-2">163邮箱：设置 → POP3/SMTP/IMAP → 开启SMTP服务</li>
                    <li class="mb-2">QQ邮箱：设置 → 账户 → POP3/IMAP/SMTP服务</li>
                    <li class="mb-2">Gmail：安全性较低的应用访问权限</li>
                </ul>
                <div class="bg-yellow-50 border-l-4 border-yellow-400 p-4 mb-6">
                    <div class="flex">
                        <div class="flex-shrink-0 text-yellow-500">
                            <i class="fas fa-exclamation-circle"></i>
                        </div>
                        <div class="ml-3">
                            <p class="text-yellow-700">
                                <strong>注意：</strong>授权码是用于代替密码的专用密码，不是邮箱登录密码。请妥善保管授权码，不要泄露给他人。
                            </p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Step 2: Dependencies -->
        <section class="mb-16">
            <div class="flex items-center mb-6">
                <div class="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-file-import text-blue-600 text-xl"></i>
                </div>
                <h2 class="text-2xl font-bold text-gray-800">2. 导入依赖</h2>
            </div>
            <div class="prose max-w-none">
                <p class="text-gray-700 mb-4">
                    在项目的<code>pom.xml</code>文件中添加Spring Boot Mail Starter依赖：
                </p>
                <div class="code-block p-4 rounded-lg mb-6 overflow-x-auto">
                    <pre class="text-sm"><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-starter-mail&lt;/artifactId&gt;
&lt;/dependency&gt;</code></pre>
                </div>
                <p class="text-gray-700">
                    这个依赖会自动引入JavaMail相关的库，使我们能够方便地使用Spring提供的邮件发送功能。
                </p>
            </div>
        </section>

        <!-- Step 3: YML Configuration -->
        <section class="mb-16">
            <div class="flex items-center mb-6">
                <div class="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-cog text-blue-600 text-xl"></i>
                </div>
                <h2 class="text-2xl font-bold text-gray-800">3. YML配置</h2>
            </div>
            <div class="prose max-w-none">
                <p class="text-gray-700 mb-4">
                    在<code>application.yml</code>或<code>application.properties</code>中配置邮件服务器参数：
                </p>
                <div class="code-block p-4 rounded-lg mb-6 overflow-x-auto">
                    <pre class="text-sm"><code class="language-yaml">spring:
  mail:
    username: 你的邮箱账号
    password: 你的授权码 #授权码
    host: smtp.163.com</code></pre>
                </div>
                <div class="bg-blue-50 border-l-4 border-blue-400 p-4 mb-6">
                    <div class="flex">
                        <div class="flex-shrink-0 text-blue-500">
                            <i class="fas fa-info-circle"></i>
                        </div>
                        <div class="ml-3">
                            <p class="text-blue-700">
                                <strong>提示：</strong>不同邮件服务器的SMTP主机地址不同，常见的有：
                            </p>
                            <ul class="list-disc pl-6 mt-2">
                                <li>163邮箱: smtp.163.com</li>
                                <li>QQ邮箱: smtp.qq.com</li>
                                <li>Gmail: smtp.gmail.com</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Step 4: Email Entity -->
        <section class="mb-16">
            <div class="flex items-center mb-6">
                <div class="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-envelope text-blue-600 text-xl"></i>
                </div>
                <h2 class="text-2xl font-bold text-gray-800">4. 封装邮件实体类</h2>
            </div>
            <div class="prose max-w-none">
                <p class="text-gray-700 mb-4">
                    创建一个简单的邮件实体类，用于封装邮件的基本信息：
                </p>
                <div class="code-block p-4 rounded-lg mb-6 overflow-x-auto">
                    <pre class="text-sm"><code class="language-java">package com.ts.blog.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Email implements Serializable {

    private String  to; // 发送给谁

    private String title; // 标题

    private String content; // 内容
}</code></pre>
                </div>
                <p class="text-gray-700">
                    这里使用了Lombok注解来简化代码，自动生成getter/setter、构造方法等。实体类包含三个基本属性：收件人、邮件标题和邮件内容。
                </p>
            </div>
        </section>

        <!-- Step 5: Email Utility -->
        <section class="mb-16">
            <div class="flex items-center mb-6">
                <div class="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-paper-plane text-blue-600 text-xl"></i>
                </div>
                <h2 class="text-2xl font-bold text-gray-800">5. 发送邮件工具类</h2>
            </div>
            <div class="prose max-w-none">
                <p class="text-gray-700 mb-4">
                    创建一个工具类封装邮件发送逻辑：
                </p>
                <div class="code-block p-4 rounded-lg mb-6 overflow-x-auto">
                    <pre class="text-sm"><code class="language-java">package com.ts.blog.utils;

import com.ts.blog.entity.Email;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

@Component
public class EmailUtils {

    @Autowired
    private JavaMailSender javaMailSender;

    @Value("${spring.mail.username}")
    private String fromEmail;

    public void send(Email email){
        // 1.创建有一个邮件对象
        MimeMessage mimeMessage = javaMailSender.createMimeMessage();

        try {
            // 2.创建一个发送邮件的帮主类
            MimeMessageHelper helper= new MimeMessageHelper(mimeMessage, true);

            helper.setTo(email.getTo()); // 收件人
            helper.setSubject(email.getTitle()); // 标题
            helper.setText(email.getContent(),true); // 内容
            helper.setFrom(fromEmail); // 发件人

            javaMailSender.send(mimeMessage); // 发送
        } catch (MessagingException e) {
            e.printStackTrace();
        }
    }
}</code></pre>
                </div>
                <p class="text-gray-700 mb-6">
                    这个工具类使用Spring的<code>JavaMailSender</code>来发送邮件，支持HTML格式的内容。通过<code>@Component</code>注解将其声明为Spring管理的Bean，可以在其他组件中自动注入使用。
                </p>
                
                <div class="bg-green-50 border-l-4 border-green-400 p-4 mb-6">
                    <div class="flex">
                        <div class="flex-shrink-0 text-green-500">
                            <i class="fas fa-lightbulb"></i>
                        </div>
                        <div class="ml-3">
                            <p class="text-green-700">
                                <strong>进阶技巧：</strong>可以扩展这个工具类，添加更多功能如：
                            </p>
                            <ul class="list-disc pl-6 mt-2">
                                <li>支持附件发送</li>
                                <li>支持模板邮件</li>
                                <li>添加邮件发送队列</li>
                                <li>实现邮件发送失败重试机制</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Step 6: Testing -->
        <section class="mb-16">
            <div class="flex items-center mb-6">
                <div class="w-12 h-12 bg-blue-100 rounded-full flex items-center justify-center mr-4">
                    <i class="fas fa-vial text-blue-600 text-xl"></i>
                </div>
                <h2 class="text-2xl font-bold text-gray-800">6. 测试邮件发送</h2>
            </div>
            <div class="prose max-w-none">
                <p class="text-gray-700 mb-4">
                    创建一个测试方法来验证邮件发送功能：
                </p>
                <div class="code-block p-4 rounded-lg mb-6 overflow-x-auto">
                    <pre class="text-sm"><code class="language-java">@Test
public void testMail(){
    Email email = new Email();
    email.setTo("854569279@qq.com");
    email.setTitle("测试标题");
    email.setContent("这里有邮件的内容&lt;a href = 'http://wwww.baidu.com'&gt;点击这里激活&lt;/a&gt;");
    emailUtils.send(email);
}</code></pre>
                </div>
                <p class="text-gray-700 mb-6">
                    运行测试方法后，检查目标邮箱是否收到测试邮件。如果一切正常，你应该能看到包含HTML链接的邮件内容。
                </p>
            </div>
        </section>

        <!-- Workflow Diagram -->
        <section class="mb-16">
            <h2 class="text-2xl font-bold text-gray-800 mb-6">邮件发送流程</h2>
            <div class="mermaid">
                graph TD
                    A[开启SMTP服务] --> B[添加邮件依赖]
                    B --> C[配置邮件参数]
                    C --> D[创建邮件实体]
                    D --> E[编写工具类]
                    E --> F[发送测试邮件]
            </div>
        </section>

        <!-- Download Section -->
        <section class="mb-16">
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-8">
                    <div class="flex items-center">
                        <div class="flex-shrink-0 bg-blue-100 p-4 rounded-lg">
                            <i class="fas fa-download text-blue-600 text-2xl"></i>
                        </div>
                        <div class="ml-6">
                            <h3 class="text-xl font-bold text-gray-800 mb-2">示例代码下载</h3>
                            <p class="text-gray-600 mb-4">获取完整的示例项目代码，快速集成到你的应用中</p>
                            <a href="https://pan.baidu.com/s/1w03htNQuKQI_vOsdmeR4Xg" 
                               class="inline-flex items-center px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors">
                                <i class="fas fa-download mr-2"></i>
                                下载代码 (提取码: 8n14)
                            </a>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-10">
        <div class="container mx-auto px-6">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-bold text-white mb-2">技术小馆</h3>
                    <p class="text-gray-400">分享前沿技术，传递编程智慧</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="hover:text-white transition-colors">
                        <i class="fas fa-globe mr-2"></i>技术小馆地址
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-400 text-sm">
                © 2024 技术小馆. 保留所有权利.
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```